package org.iks.user.enums;

import lombok.Getter;
import org.iks.common.enums.IEnum;

import java.util.Objects;

/**
 * Author kzou
 * Date 2024/5/23
 * Description: 添加方式来源
 */
@Getter
public enum ApplySourceType implements IEnum<Integer> {

    /**
     * 其他方式添加的好友
     */
    Unknown(-1, "未知"),

    /**
     * 扫描二维码方式添加的好友
     */
    QR(1, "二维码"),

    /**
     * 账号搜索添加的好友
     */
    Search(2, "搜搜"),

    ;

    private final int code;

    private final String desc;

    ApplySourceType(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static ApplySourceType of(Integer code) {
        for (ApplySourceType sourceType : values()) {
            if (Objects.equals(code, sourceType.code)) {
                return sourceType;
            }
        }
        return Unknown;
    }

    @Override
    public Integer getUniqueCode() {
        return code;
    }

}
